package com.ruoyi.management_controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.management_controller.liaison_station.LiaisonStation.service.ILiaisonStationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.management_controller.liaison_station.StreetInfo.domain.StreetInfo;
import com.ruoyi.management_controller.liaison_station.StreetInfo.service.IStreetInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 街道信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/StreetInfo/StreetInfo")
public class StreetInfoController extends BaseController
{
    @Autowired
    private IStreetInfoService streetInfoService;

    @Autowired
    private ILiaisonStationService liaisonStationService;

    /**
     * 查询街道信息列表
     */
//    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(StreetInfo streetInfo)
    {
        startPage();
        List<StreetInfo> list = streetInfoService.selectStreetInfoList(streetInfo);
        return getDataTable(list);
    }


    @GetMapping("/all")
    public TableDataInfo all(StreetInfo streetInfo)
    {
        startPage();
        List<StreetInfo> list = streetInfoService.selectStreetInfoList(streetInfo);
        return getDataTable(list);
    }

    @GetMapping("/findByName")
    public  List<StreetInfo> findByName(StreetInfo streetInfo)
    {
        List<StreetInfo> list = streetInfoService.selectStreetInfoList(streetInfo);
        return list;
    }
    /**
     * 导出街道信息列表
     */
    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:export')")
    @Log(title = "街道信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StreetInfo streetInfo)
    {
        List<StreetInfo> list = streetInfoService.selectStreetInfoList(streetInfo);
        ExcelUtil<StreetInfo> util = new ExcelUtil<StreetInfo>(StreetInfo.class);
        util.exportExcel(response, list, "街道信息数据");
    }

    /**
     * 获取街道信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(streetInfoService.selectStreetInfoById(id));
    }

    /**
     * 新增街道信息
     */
    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:add')")
    @Log(title = "街道信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StreetInfo streetInfo)
    {
        return toAjax(streetInfoService.insertStreetInfo(streetInfo));
    }

    /**
     * 修改街道信息
     */
    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:edit')")
    @Log(title = "街道信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StreetInfo streetInfo)
    {
        return toAjax(streetInfoService.updateStreetInfo(streetInfo));
    }

    /**
     * 删除街道信息
     */
    @PreAuthorize("@ss.hasPermi('StreetInfo:StreetInfo:remove')")
    @Log(title = "街道信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(streetInfoService.deleteStreetInfoByIds(ids));
    }
}
